package com.bclz.baseLearn

import scala.collection.Seq

object TestList {

  def main(args: Array[String]) {

    val programmarLans = List("Java", "Python", "Scala", "C", "C++")
    val programmarLans1 = List.apply("Javax", "Pythonx", "Scalax", "Cx", "C++x");
    val programmarLans2 = "Java" :: "Python" :: "Scala" :: "C" :: "C++" :: Nil
    println(programmarLans.dropWhile(s=>s=="Python"||s=="Java"));
    println("所有元素:" + programmarLans)
    println("通过下标获取第一个元素:" + programmarLans.apply(0))
    println("获取第一个元素:%s" format programmarLans.head)
    println("获取除第一个元素以外的所有元素List:" + programmarLans.tail)
    //循环列表
    for (c <- programmarLans) {
      println(c)
    }
    val (xprogrammarLans,xprogrammarLans1)=(programmarLans,programmarLans1)
    //合并列表
    val programmarLansOthers = "JavaScript" :: "Lisp" :: Nil
    val programmarLansNews = programmarLans ::: programmarLansOthers
    println(programmarLansNews)
    val copy3=List.fill(3)(programmarLans,programmarLans1)
    println(copy3);
    println(copy3.unzip);

  }

}

object TestSet {

  def main(args: Array[String]) {

    val programmarLans = Set("Java", "Python", "Scala", "C", "C++", "C")
    println(programmarLans)
    println("包含Java1:" + programmarLans.apply("Java1"))
    println("拼接集合:" + (programmarLans ++ Set("Java", "go", "sql")))

  }

}

object TestMap {

  def main(args: Array[String]) {

    val programmarLansUser = Map("xuchang" -> "Java", "bclz" -> "Scala")
    val newMap = programmarLansUser+("11"->"11")
    println(programmarLansUser)
    println("拼接Map:" + (programmarLansUser ++ Map("sky" -> "Python")))
    println("查找xuchang的Map:" + programmarLansUser.apply("xuchang"))
  }

}

object TestTuple {

  def main(args: Array[String]) {

    val tuple1 = ("Scala", 18, 17 :: 18 :: Nil)
    //Tuple1包含1个元素的元组,Tuple2包含2个元素的元组,Tuple3包含3个元素的元组..Tuple22依此类推
    val tuple2 = new Tuple3("Scala", 18, 17 :: 18 :: Nil)
    val tuple3 = Tuple3("Scala", 18, 17 :: 18 :: Nil)
    val tuple4 = Tuple3[String, Int, List[String]]("Scala", 18, "xuchang" :: "bclz" :: Nil)
    val (programmarLan, name, age) = ("Scala", "xuchang", 12)

    println(tuple1)

    println("编程语言:%s-姓名:%s-年纪:%d" format (programmarLan, name, age))

  }

}

object TestIterator {

  def main(args: Array[String]) {
    val i = Iterator(1, 2, 3)
    val s = Seq(1, 2, 3)

    val si=s.iterator;
    while(si.hasNext){

    }

  }

}


